<?php

class MySpaceException extends Exception {
  const TOKEN_REQUIRED = 1;
  const REMOTE_ERROR   = 2;
  const REQUEST_FAILED = 3;
  const CONNECT_FAILED = 4;

  public $response;
  
  public static $MS_DUMP_REQUESTS = './ms.error.log';

  function __construct($msg, $code, $response=null) {
    parent::__construct($msg, $code);
    $this->response = $response;
    
    $datetime = new DateTime();
    $datetime =  $datetime->format(DATE_ATOM);
    
    file_put_contents(self::$MS_DUMP_REQUESTS, 
	    "\r\n====================================================\r\n".
	    "time: $datetime\r\n" .
	    "message:\r\n--------------------------\r\n$msg\r\n\r\n" .
	    "code:\r\n----------------------------\r\n$code\r\n\r\n" .
	    "response:\r\n----------------------------\r\n$response\r\n\r\n",
			FILE_APPEND);
    
  }
}

?>